class administrator():
    def __init__(self, name, password):
        self.name = name
        self.password = password

    def add_school(self):
        new_school = school(input('请输入要添加学校名称：'), input('请输入该学校地址：'))
        print()
        return new_school

    def add_course(self):
        new_course = course(input('请输入要添加课程名称：'))
        print()
        return new_course

    def add_teacher(self):
        new_teacher = teacher(input('请输入要添加老师名称：'), int(input('请输入密码：')))
        print()
        return new_teacher


class teacher:
    def __init__(self, name, password):
        self.name = name
        self.password = password

    def add_course(self):
        new_course = course(input('请输入要添加课程名称：'))
        print()
        return new_course

    def rating(self):
        stu_name = input('请输入要打分学生姓名：')
        cou_name = input('请输入要打分科目：')
        if stu_name == stu1.name and cou_name == cou1.name:
            grade = input('请输入该学生成绩：')
            print(f"{stu_name}的{cou_name}成绩为：{grade}")
        elif stu_name not in student.__name__:
            print(f"没有名叫{stu_name}的学生")
        elif cou_name not in course.__name__:
            print(f"{stu_name}同学没有购买{cou_name}课程")



class student:
    def __init__(self, name, password):
        self.name = name
        self.password = password

    def search(self):
        sch_name = input('请输入要选择学校名称：')
        cou_name = input('请输入课程名称：')
        if sch_name == sch1.name and cou_name == cou1.name:
            print(f'您是否要选择{sch_name}的{cou_name}课程')
            s = input('Y/N')
            if s == 'Y':
                print('选择成功！')
            else:
                return
        elif sch_name != sch1.name:
            print(f'没有{sch_name}，您不能选择！')
        else:
            print(f'{sch_name}没有{cou_name}课程，您不能选择！')
        print()

class school:
    def __init__(self, name, addr):
        self.name = name
        self.addr = addr

    def add_course(self):
        new_course = course(input('请输入要添加课程名称：'))
        print()
        return new_course


class course:
    def __init__(self, name):
        self.name = name

    def add_student(self):
        new_student = student(input('请输入要添加学生姓名：'), input('请输入密码：'))
        print()
        return new_student


adm1 = administrator('管理员', 123456)
sch1 = adm1.add_school()
cou1 = adm1.add_course()
tea1 = adm1.add_teacher()
stu1 = cou1.add_student()
stu1.search()
tea1.rating()